<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="/WEB-INF/templates/common/taglib.jsp"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <title>${title}</title>
    <link rel="stylesheet" href="${basePath}/static/bootstrap/css/bootstrap.css"/>
    <link href="${basePath}/static/css/basic.css" rel="stylesheet" type="text/css">
    <link href="${basePath}/static/css/login.css" rel="stylesheet" type="text/css">
    <link href="${basePath}/static/css/list.css" rel="stylesheet" type="text/css">
   <%--  <link rel="stylesheet" href="${basePath}/static/css/content_leftNav.css"/>
    <link rel="stylesheet" href="${basePath}/static/css/FrontControl.css"/>
     --%><script  type="text/javascript" src="${basePath}/static/js/jquery.min.js"></script>
	<script  type="text/javascript" src="${basePath}/static/My97DatePicker/WdatePicker.js"></script>
	<script type="text/javascript" src="${basePath}/static/page/jqPaginator/jqPaginator.js"></script>
    <script  type="text/javascript" src="${basePath}/static/layer/layer.js"></script>
	<link href="${basePath}/static/layer/layer_style.css" rel="stylesheet" type="text/css">

</head>
<body>
<!--头部-->
	<%@include file="/WEB-INF/templates/common/header.jsp"%>
	<!------导航条-->
	<%@include file="/WEB-INF/templates/common/navigation.jsp"%>

<!--内容部分-->
<div class="list_main lay_out" class="clearfix">
    <div class="list_DH">
        <%@include file="/WEB-INF/templates/common/qualityNav.jsp"%>
    </div>
    <div class="list_NR">
        <div class="loc">
            <h3 style="margin:0;font-size:16px">质控统计查询</h3>
        </div>
        <div class="list_con_table">
            <div class="search_table" style="height:70px">
                <ul class="clearfix">
                 	<%-- <li class="Label_1">出院科室：&nbsp;</li>
                 	 <li class="Label_2">
                 	 	<select class="input_box" style="width:90%" id=officeName>
               				<option value="">请选择</option>
               				<c:forEach var="office" items="${officeList }"> 
               					<option value="${office.id }">${office.name}</option>
               				</c:forEach>
                	</select>
                 	 </li> --%>
                    <li class="Label_1">出院日期：&nbsp;</li>
                    <li class="Label_4" style="text-align: left;padding-left:4px;"><input class="input_box" style="width:150px;" type="text"  name='startTime' id='startTime' value='${params.startTime}' onFocus="WdatePicker()" /><span>&nbsp;-&nbsp;</span><input class="input_box" type="text" style="width:150px;"  name='endTime' id='endTime' value='${params.endTime}' onFocus="WdatePicker()" /></li>
                    <li class="Label_5">
                        <div class="right" style="text-align:right">
                            <a onclick="searchQua()">查询</a>  
                         <!--    <a onclick="exportExcel()">导出</a>  -->
                        </div>
                    </li>
                  
                </ul>
            </div> 
             <table class="Search_tableList" cellpadding="0" cellspacing="0">
                <tr style="display:none" id="qualityHeader">
                  
                  <!--   <td class="tdLabel_6" colspan="10" id="totalQuality" >出院总数:100
								 &nbsp;&nbsp;质控总数:20
								  &nbsp;&nbsp;质控率:20%</td> -->

                </tr>
                <tr>
                  
                    <td class="tdLabel_4"  >科室名称</td>
                    <td class="tdLabel_4">出院数</td>
                    <td class="tdLabel_4" >质控数</td>
                    <td class="tdLabel_4" >质控率(%)</td>
                    <td class="tdLabel_4"  >甲级质控数</td>
                    <td class="tdLabel_4" >乙级质控数</td>
                    <td class="tdLabel_4"  >丙级质控数</td>

                </tr>
       
                <tr id="loading" style="height:50px;display:none">
	             <td colspan="10" align="center" ><img src="${basePath}/static/layer/skin/default/loading-2.gif"></td>
	            </tr>
               <!--   <tr>
                  
                    <td class="tdLabel_4" style="width:10%">质控数</td>
                    <td class="tdLabel_4" style="width:10%">质控率(%)</td>
                    <td class="tdLabel_4" style="width:10%">质控数</td>
                    <td class="tdLabel_4" style="width:10%">质控率(%)</td>
                    <td class="tdLabel_4" style="width:10%">质控数</td>
                    <td class="tdLabel_4" style="width:10%">质控率(%)</td>
                </tr> -->
                
                <tbody id="tbody">
                
                </tbody>
            </table>
        </div>
        <!-- <!-- <div class="pageList">
            <ul class="pagination clearfix" id="page_plus"></ul>
            <div class="pagination">
                <div>总共：<b id="totalPage">0</b> 条信息    当前页是第 <b id="currentPage">0/0</b>　页</div>
            </div>
        </div> --> 
    </div>
</div>
<!------页脚部分--------->
<%@include file="/WEB-INF/templates/common/footer.jsp"%>

<!--JS部分-->
<script type="text/javascript">
	
	function searchQua(){
		queryQua();
	}

	function queryQua(){
		var startTime=$("#startTime").val();
		var endTime=$("#endTime").val();
		var officeId=$("#officeName").val();
		
		if(!startTime && !endTime && !officeName){
			layer.alert("请输入查询条件!",{icon:0});
			return;
		}
		jQuery.support.cors = true;
		$.ajax({
			type:"post",
			url:"${basePath}/quality/getMedRecordQualityRate",
			data:{outHospitalStartDate:startTime,outHospitalEndDate:endTime,outHospitalOfficeId:officeId},
			beforeSend:function(){
    	 		$("#tbody").html("");
    	 		$("#loading").show();
    	 	},
			success:function(data){
				//console.log(data);
				
				$("#loading").hide();
				var quaList=data.data.qualityList;
				var outHospitalTotalCount = data.data.outHospitalTotalCount;
				var qualityTotalCount = data.data.qualityTotalCount;
				var qualityTotalRate = data.data.qualityTotalRate;
				if(quaList!=null && quaList!=""){
					var html="";
					for(var i=0;i<quaList.length;i++){
						var obj=quaList[i];
						html+="<tr>"+
							  "	<td class='tdLabel_5'>"+obj.name+"</td>"+
	                    	  "	<td class='tdLabel_5'>"+obj.outHospitalCount+"</td>"+
	                     	  " <td class='tdLabel_5'><a style='color:red' officeCode='"+obj.code+"' qualityCount='"+obj.qualityCount+"' onclick='quality(this)'>"+obj.qualityCount+"</a></td>"+
	                          " <td class='tdLabel_5'>"+obj.qualityRate+"</td>"+
	                    	  "	<td class='tdLabel_5'><a style='color:red' officeCode='"+obj.code+"'  maxPoints='15' minPoints='0'  levelCount='"+obj.levelACount+"'  onclick='qualityLevel(this)'> "+obj.levelACount+"</a></td>"+
	                         /*  "	<td class='tdLabel_5'>"+obj.levelARate+"</td>"+ */
	                          " <td class='tdLabel_5'><a style='color:red' officeCode='"+obj.code+"' maxPoints='30' minPoints='15'  levelCount='"+obj.levelBCount+"'  onclick='qualityLevel(this)'>"+obj.levelBCount+"</td>"+
	                         /*  "	<td class='tdLabel_5'>"+obj.levelBRate+"</td>"+ */
	                    	  "	<td class='tdLabel_5'><a style='color:red' officeCode='"+obj.code+"' maxPoints='100' minPoints='30' levelCount='"+obj.levelCCount+"'  onclick='qualityLevel(this)'>"+obj.levelCCount+"</a></td>"+
	                    	 /*  "	<td class='tdLabel_5'>"+obj.levelCRate+"</td>"+ */
	                    	  "</tr>";
						
					}
					var qualityTotal="";
					qualityTotal+="<td class='tdLabel_6' colspan='10' id='totalQuality' >出院总数:"+outHospitalTotalCount+""+
					 			  "	&nbsp;&nbsp;质控总数:"+qualityTotalCount+""+
					 			  "	 &nbsp;&nbsp;质控率:"+qualityTotalRate+"%</td>";

					
					$("#tbody").html("").html(html);
					$("#qualityHeader").html(qualityTotal).show();
				}else{
					layer.alert("数据为空!",{icon:5});
					$("#tbody").html("");
					//window.location.href="${basePath}/quality/findQuality";
				}
			},
			error:function(data){
				$("#loading").hide();
				layer.alert("服务器错误",{icon:5});
			}
		})
		
	}
	
	 function page(currentPage,totalCounts){
	    	//var totalCounts = 1000;
	        var pageSize = 2;
	        var visiblePages = 5;
	        //var currentPage = 1;
	        /* var totalPages = totalCounts%pageSize==0?(totalCounts/pageSize):(totalCounts/pageSize+1); */
	        var totalPages = Math.ceil(totalCounts/pageSize);
	        $('#page_plus').jqPaginator({

	            totalCounts: totalCounts,
	            pageSize:pageSize,
	            visiblePages: visiblePages,
	            currentPage: currentPage,

	            first:'<li class="first"><a href="javascript:void(0);">首页</a></li>',
	            prev: '<li class="prev"><a href="javascript:void(0);">上一页</a></li>',
	            next: '<li class="next"><a href="javascript:void(0);">下一页</a></li>',
	            last: '<li class="last"><a href="javascript:void(0);">末页</a></li>',
	            page: '<li class="page"><a href="javascript:void(0);">{{page}}</a></li>',
	            onPageChange: function (num,type) {
	            	
	            	 if(type !='init'){
	                 
	            		 queryQua(num-1,pageSize);
	                 }
	            	
	                $("#totalPage").html(totalCounts);
	                $("#currentPage").html(num+"/"+totalPages);
	            }
	        });

	    }
	 
	 
	function quality(obj){
		var $this=$(obj);
		
		var qualityCount=$this.attr("qualityCount");
		if(qualityCount==0){
			layer.alert("数据为空!",{icon:5});
			return;
		}
		var startTime=$("#startTime").val();
		var endTime=$("#endTime").val();
		var officeCode=$this.attr("officeCode");
		
		
		window.open("${basePath}/quality/findQuality?startTime="+startTime+"&endTime="+endTime+"&officeId="+officeCode+"&type=qualityStatic")
		//window.location.href="${basePath}/quality/findQuality?startTime="+startTime+"&endTime="+endTime+"&officeId="+officeCode+"&type=qualityStatic"
		
	}
	
	
	function qualityLevel(obj){
		var $this=$(obj);
		var levelCount=$this.attr("levelCount");
		var maxPoints= $this.attr("maxPoints");
		var minPoints= $this.attr("minPoints");
		var startTime=$("#startTime").val();
		var endTime=$("#endTime").val();
		var officeCode=$this.attr("officeCode");
		if(levelCount==0){
			layer.alert("数据为空!",{icon:5});
			return;
		}
		
		
		window.open("${basePath}/quality/findQuality?startTime="+startTime+"&endTime="+endTime+"&officeId="+officeCode+"&type=qualityStatic&medLevel=level&maxPoints="+maxPoints+"&minPoints="+minPoints+"")
		

		
		
		
	}
</script>

</body>
</html>